package com.rongmai.web.bo;

import com.rongmai.db.mapper.FinanceProductAuditMapper;
import com.rongmai.db.model.FinanceProductAudit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Slf4j
@Service
public class FinanceProductBo {

    @Resource
    private FinanceProductAuditMapper financeProductAuditMapper;

    public void add(FinanceProductAudit financeProduct) {
        financeProduct.setCreateTime(new Date());
        financeProductAuditMapper.insert(financeProduct);
    }

    public void edit(FinanceProductAudit param) {
        FinanceProductAudit financeProduct = get(Long.valueOf(param.getId()));
        BeanUtils.copyProperties(param, financeProduct);
        financeProductAuditMapper.updateByPrimaryKeySelective(financeProduct);
    }

    public FinanceProductAudit get(Long id) {
        return financeProductAuditMapper.selectByPrimaryKey(id);
    }

    public void delete(Long id) {
        financeProductAuditMapper.deleteByPrimaryKey(id);
    }
}
